# Maintainer: Rémy Oudompheng <remy@archlinux.org>

pkgname=biber
epoch=1
pkgver=2.19
pkgrel=1
pkgdesc="A Unicode-capable BibTeX replacement for biblatex users"
arch=('any')
license=('PerlArtistic' 'GPL')
url="https://github.com/plk/biber"
# Encode::* modules are not real dependencies.
depends=('perl-autovivification'
         'perl-business-isbn'
         'perl-business-ismn'
         'perl-business-issn'
         'perl-class-accessor'
         'perl-data-compare'
         'perl-data-dump'
         'perl-data-uniqid'
         'perl-datetime-calendar-julian'
         'perl-datetime-format-builder'
         'perl-file-slurper'
         'perl-io-string' # required by Biber::Output::bblxml
         'perl-ipc-run3'
         'perl-lingua-translit'
         'perl-list-allutils'
         'perl-log-log4perl'
         'perl-lwp-protocol-https'
         'perl-mozilla-ca'
         'perl-parse-recdescent'
         'perl-perlio-utf8-strict'
         'perl-regexp-common'
         'perl-sort-key'
         'perl-text-balanced'
         'perl-text-bibtex'
         'perl-text-csv'
         'perl-text-roman'
         'perl-unicode-linebreak'
         'perl-xml-libxml-simple'
         'perl-xml-libxslt'
         'perl-xml-writer')
# ExtUtils::LibBuilder and Config::AutoConf are not actual makedepends
makedepends=('perl-module-build' 'perl-test-differences')
checkdepends=('perl-capture-tiny' 'perl-file-which'
              'texlive-bibtexextra'
              'texlive-latexextra')
options=('!emptydirs')
# The sourceforge tarball is missing bblxml.pm
source=("https://github.com/plk/biber/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz"
        "test.tex"
        "test.bib")
sha512sums=('427edd042e25fd6b763d60ad5bd3ce6fb68f9d6b15dfe387edc8c8445022cb2a4ba0999d7890fc51798dd95cbe82f82f6fc40b58df5a502c9c9b8485806c56d5'
            '06babeb4ec2fd76b8a339070eb208c3c8c16665a085e4674ef3b61b3816d4408ca636b925fabe467adc5c32bf8eeb23d357f7ef979ac0a1722dc7f91142ec541'
            '68a00e41f200b8e24a674538b6581b88f84daef38a765790c1781365329203f60f4461a56dfa092bf336cc00c8801df1ee85f60d86fd384a8c039f913bdeeb2d')

prepare() {
  cd "${srcdir}/biber-${pkgver}"

  mkdir -p "test"
  cp "${srcdir}"/test.{tex,bib} test/
}

build() {
  cd "${srcdir}/biber-${pkgver}"
  unset PERL5LIB PERL_MM_OPT PERL_MB_OPT PERL_LOCAL_LIB_ROOT
  perl Build.PL
  ./Build
}

check() {
  cd "${srcdir}/biber-${pkgver}"
  # Test a sample file
  pushd test
  latex test
  PERL5LIB=../blib/lib ../bin/biber test
  latex test
  popd
  # Run test suite
  unset PERL5LIB PERL_MM_OPT PERL_MB_OPT PERL_LOCAL_LIB_ROOT
  LC_CTYPE=en_US.UTF-8 BIBER_DEV_TESTS=1 ./Build test
}

package() {
  cd "${srcdir}/biber-${pkgver}"
  unset PERL5LIB PERL_MM_OPT PERL_MB_OPT PERL_LOCAL_LIB_ROOT
  ./Build install installdirs=vendor destdir="${pkgdir}"
}
